package com.siyu.preplan.planpfbase.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.siyu.common.core.controller.BaseController;
import com.siyu.common.core.domain.AjaxResult;
import com.siyu.common.core.page.TableDataInfo;
import com.siyu.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.siyu.preplan.planpfbase.domain.PlanPFbase;
import com.siyu.preplan.planpfbase.service.IPlanPFbaseService;

/**
 * 预案行政区淹没影响数据Controller
 *
 * @author hrhy
 * @date 2024-08-06
 */
@RestController
@RequestMapping("/planpfbase/PlanPFbase")
public class PlanPFbaseController extends BaseController
{
    @Autowired
    private IPlanPFbaseService planPFbaseService;

    /**
     * 查询预案行政区淹没影响数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PlanPFbase planPFbase)
    {
        startPage();
        List<PlanPFbase> list = planPFbaseService.selectPlanPFbaseList(planPFbase);
        return getDataTable(list);
    }

    /**
     * 导出预案行政区淹没影响数据列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanPFbase planPFbase)
    {
        List<PlanPFbase> list = planPFbaseService.selectPlanPFbaseList(planPFbase);
        ExcelUtil<PlanPFbase> util = new ExcelUtil<PlanPFbase>(PlanPFbase.class);
        util.exportExcel(response, list, "预案行政区淹没影响数据数据");
    }

    /**
     * 获取预案行政区淹没影响数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(planPFbaseService.selectPlanPFbaseById(id));
    }

    /**
     * 新增预案行政区淹没影响数据
     */
    @PostMapping
    public AjaxResult add(@RequestBody PlanPFbase planPFbase)
    {
        return toAjax(planPFbaseService.insertPlanPFbase(planPFbase));
    }

    /**
     * 修改预案行政区淹没影响数据
     */
    @PutMapping
    public AjaxResult edit(@RequestBody PlanPFbase planPFbase)
    {
        return toAjax(planPFbaseService.updatePlanPFbase(planPFbase));
    }

    /**
     * 删除预案行政区淹没影响数据
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(planPFbaseService.deletePlanPFbaseByIds(ids));
    }
}
